package com.neuedu.web.controller.yunong;

import java.util.List;

import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.common.annotation.Log;
import com.neuedu.common.core.controller.BaseController;
import com.neuedu.common.core.domain.AjaxResult;
import com.neuedu.common.enums.BusinessType;
import com.neuedu.yunong.domain.YunongVideos;
import com.neuedu.yunong.service.IYunongVideosService;
import com.neuedu.common.utils.poi.ExcelUtil;
import com.neuedu.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 视频管理Controller
 *
 * @author mxwj
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/experts/videos")
@Tag(name = "【视频管理】管理")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class YunongVideosController extends BaseController
{
    private final IYunongVideosService yunongVideosService;

    /**
     * 查询视频管理列表
     */
    @Operation(summary = "查询视频管理列表")
    @PreAuthorize("@ss.hasPermi('experts:videos:list')")
    @GetMapping("/list")
    public TableDataInfo list(YunongVideos yunongVideos)
    {
        startPage();
        List<YunongVideos> list = yunongVideosService.selectYunongVideosList(yunongVideos);
        return getDataTable(list);
    }

    /**
     * 查询视频管理列表（增加按字段降序排序）
     */
    @Operation(summary = "查询视频管理列表（增加按字段降序排序）")
    @PreAuthorize("@ss.hasPermi('experts:videos:listDesc')")
    @GetMapping("/list-plus")
    public TableDataInfo listDesc(YunongVideos yunongVideos, String orderBy)
    {
    startPage();
    List<YunongVideos> list = yunongVideosService.selectYunongVideosListPlus(yunongVideos, orderBy);
    return getDataTable(list);
    }




    /**
     * 导出视频管理列表
     */
    @Operation(summary = "导出视频管理列表")
    @PreAuthorize("@ss.hasPermi('experts:videos:export')")
    @Log(title = "视频管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YunongVideos yunongVideos)
    {
        List<YunongVideos> list = yunongVideosService.selectYunongVideosList(yunongVideos);
        ExcelUtil<YunongVideos> util = new ExcelUtil<YunongVideos>(YunongVideos.class);
        util.exportExcel(response, list, "视频管理数据");
    }

    /**
     * 获取视频管理详细信息
     */
    @Operation(summary = "获取视频管理详细信息")
    @PreAuthorize("@ss.hasPermi('experts:videos:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yunongVideosService.selectYunongVideosById(id));
    }

    /**
     * 新增视频管理
     */
    @Operation(summary = "新增视频管理")
    @PreAuthorize("@ss.hasPermi('experts:videos:add')")
    @Log(title = "视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YunongVideos yunongVideos)
    {
        return toAjax(yunongVideosService.insertYunongVideos(yunongVideos));
    }

    /**
     * 修改视频管理
     */
    @Operation(summary = "修改视频管理")
    @PreAuthorize("@ss.hasPermi('experts:videos:edit')")
    @Log(title = "视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YunongVideos yunongVideos)
    {
        return toAjax(yunongVideosService.updateYunongVideos(yunongVideos));
    }

    /**
     * 删除视频管理
     */
    @Operation(summary = "删除视频管理")
    @PreAuthorize("@ss.hasPermi('experts:videos:remove')")
    @Log(title = "视频管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable( name = "ids" ) Long[] ids)
    {
        return toAjax(yunongVideosService.deleteYunongVideosByIds(ids));
    }
}
